#include "mainwindow.h"
#include "ui_mainwindow.h"


MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    carve=new CarvingModule;

//    while(1)
//    {

//        long period=1;
//        int arg=1;
////        emcmotCommandHandler(&arg, period);
////        emcmotController(&arg, period);
////        usleep(1000);//hualei
////        emcmotSetCycleTime(1);

////        CUBIC_STRUCT  *ci;
////        cubicInit(ci);
//    }


}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::updatePeriod()
{

}

void MainWindow::on_pushButton_addline_clicked()
{
    int idIn=ui->lineEdit_id->text().toInt();
    double x=ui->lineEdit_x->text().toDouble();
    double y=ui->lineEdit_y->text().toDouble();
    double z=ui->lineEdit_z->text().toDouble();
    double w=ui->lineEdit_w->text().toDouble();
    double p=ui->lineEdit_p->text().toDouble();
    double r=ui->lineEdit_r->text().toDouble();
    double vel=ui->lineEdit_vel->text().toDouble();
    double acc=ui->lineEdit_acc->text().toDouble();

    carve->addLine(idIn, x,  y,  z,  w,  p,  r,
                    vel,  acc);
    idIn++;
    ui->lineEdit_id->setText(QString::number(idIn));
}

void MainWindow::on_pushButton_pause_clicked()
{
    carve->emcTpPause();
}

void MainWindow::on_pushButton_resume_clicked()
{
    carve->emcTpResume();
}

void MainWindow::on_pushButton_clear_clicked()
{
    carve->emcTpClear();
}
